<?php
class StatusController extends Zend_Controller_Action
{
	protected $_acl;
	protected $_userGroup;
	
	public function init()
	{
		$auth = Zend_Auth::getInstance();
		$userInfo = $auth->getStorage()->read();
		$groupBase = new GroupBase();
		if ($userInfo) {
			$userGroups = $groupBase->getUserGroup($userInfo->name);
		}
		$this->_userGroup = $userGroups[0]['name'] ? $userGroups[0]['name'] : "Users";
		$this->_acl = new Acl_PPMIS();
		$this->view->acl = $this->_acl;
		$this->view->userGroup = $this->_userGroup;
	}
	
	public function preDispatch()
	{
		$auth = Zend_Auth::getInstance();
		if($auth->getIdentity()) {
			$this->view->auth = "success";
			$userInfo = $auth->getStorage()->read();
			$this->view->userInfo = $userInfo;
		} else {
			$this->_redirect('auth/login');
		}
		$Configuration = new Configuration();
		$configurationData = $Configuration->getConfigurationInfo();
		$this->view->configuration = $configurationData;
		$this->view->current = "admin";
	}
	
	public function manageAction()
	{
		$IssueStatus = new IssueStatus();
		$data = $IssueStatus->fetchAll($IssueStatus->select());
		
		$form = new AddIssueStatusForm();
		
		if ($this->getRequest()->isPost()) {
			$formData = $this->_request->getPost();
			if ($form->isValid($formData)) {
				Zend_Debug::dump($formData);
			}
		}
		$this->view->form = $form;
		$this->view->data = $data;
	}
}